#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
    printf("process is running...\n");
    pid_t id = fork();
    assert(id != -1);

    if(id == 0)
    {
        sleep(1);
        //execl("/usr/bin/ls"/*要执行哪一个程序*/,"ls","-a", "-l", "--color=auto", NULL);//all exec* end of NULL
        //execlp("ls","ls","-a", "-l", "--color=auto", NULL);//all exec* end of NULL
        //char *const argv_[] = {
            //"ls",
            //"-a",
            //"-l",
            //"--color=auto",
            //NULL
        //};
        //execv("/usr/bin/ls", argv_);
        //execvp("ls", argv_);
        execl("./mybin","mybin",NULL);
        exit(1);
    }

    int status = 0;
    pid_t ret = waitpid(id, &status, 0);
    if(ret > 0) printf("wait success: exit code: %d, sig: %d\n", (status>>8)&0xFF, status & 0x7F);
}
